import { Injectable } from '@angular/core';
import {ToastController} from "ionic-angular";

@Injectable()
export class ValidateUtils {
  public phone(phone: string): boolean {
    // let regx = /^[0-9]{11}$/;
    let regx = /^((1[3,5,8][0-9])|(14[5,7])|(17[0,3,6,7,8])|(19[7]))\d{8}$/;
    if (!regx.test(phone)) {
      return false;
    }
    return true;
  }

  public showtoast(message:string,toastCtrl:ToastController,location:string):void {
    toastCtrl.create({
      message: message,
      cssClass: 'toast-container',
      duration: 2000,
      position: location
    }).present()
  }
}
